package com.example.test.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

//@Configuration
//@ConfigurationProperties(prefix = "spring.redis")
@Data
public class MyRedissonConfig {

    private String host;
    private String port;

    @Bean(destroyMethod = "shutdown")
    RedissonClient redissonClient() {
        //1、创建配置
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://" + host + ":" + port);
        return Redisson.create(config);
    }

}